//
// UnaryIterativeMethod.cpp
// Abstract base class for iterative methods that take one argument.
//
// Author: Gabriel H. Barbuto (gbarbuto@dc.uba.ar)
//
#include <cstddef>
#include <stdexcept>
#include <vector>

#include "UnaryIterativeMethod.h"

UnaryIterativeMethod::UnaryIterativeMethod(std::size_t const &iterations) :
IterativeMethod(iterations)
{
}

UnaryIterativeMethod::UnaryIterativeMethod(double const &epsilon, std::size_t const &iterations) :
IterativeMethod(epsilon, iterations)
{
}

double UnaryIterativeMethod::operator()(double const &x)
{
	double const argument_values[] = { x };
	std::vector<double> const arguments(argument_values, argument_values + UnaryIterativeMethod::argument_count());

	return (*this)(arguments);
}

void UnaryIterativeMethod::check(std::vector<double> const &arguments) const
{
	if (arguments.size() != UnaryIterativeMethod::argument_count())
	{
		throw std::logic_error("Wrong argument count");
	}
}

